import java.util.*;

@SuppressWarnings("unchecked")
public class p1015_4_922ms {

	public static//
	// -----
	// -----
	/*
	 * import java.util.*; /*
	 */
	class Main {
		public static void main(String[] args) throws Exception {
			Scanner in = new Scanner(System.in);
			int id = 0;
			while (true) {
				int n = in.nextInt();
				int m = in.nextInt();
				if (n + m <= 0)
					break;

				int[][] input = read(in, n);
				int[] juries = process(n, m, input);
				System.gc();

				int sump = 0, sumd = 0;
				for (int i : juries) {
					sump += input[i][0];
					sumd += input[i][1];
				}

				System.out.print("Jury #" + (++id) + "\nBest jury has value " + sump + " for prosecution and value "
						+ sumd + " for defence:\n");
				for (int i : juries)
					System.out.print(" " + (i + 1));
				System.out.print("\n\n");
			}
		}

		static int[][] read(Scanner in, int n) throws Exception {
			int[][] input = new int[n][];
			for (int i = 0; i < n; i++) {
				int pi = in.nextInt();
				int di = in.nextInt();
				input[i] = new int[] { pi, di, pi - di, pi + di };
			}
			return input;
		}

		static int[] process(int n, int m, int[][] input) {
			// data: for m in n, each dif -> max sum
			Map<Integer, Object[]>[] dp = new Map[m + 1];
			for (int j = 0; j <= m; j++)
				dp[j] = new HashMap<Integer, Object[]>();
			dp[0].put(0, new Object[] { 0, -1, null });

			// dp
			for (int i = 0; i < n; i++) {
				for (int j = m; j > 0; j--) {
					Map<Integer, Object[]> dpMap = dp[j];
					for (Map.Entry<Integer, Object[]> entry : dp[j - 1].entrySet()) {
						int dif = input[i][2] + entry.getKey();
						int sum = input[i][3] + (Integer) entry.getValue()[0];
						if (!dpMap.containsKey(dif) || sum > (Integer) dpMap.get(dif)[0]) {
							dpMap.put(dif, new Object[] { sum, i, entry.getValue() });
						}
					}
				}
			}

			// find final answer
			int abs = Integer.MAX_VALUE, sum = -1;
			Object[] linkedList = null;
			for (Map.Entry<Integer, Object[]> entry : dp[m].entrySet()) {
				int curDIf = entry.getKey();
				int curAbs = Math.abs(curDIf);
				if (abs > curAbs) {
					linkedList = entry.getValue();
					abs = curAbs;
					sum = (Integer) entry.getValue()[0];
				} else if (abs == curAbs && (Integer) entry.getValue()[0] > sum) {
					linkedList = entry.getValue();
					sum = (Integer) entry.getValue()[0];
				}
			}

			// output
			int[] juries = new int[m];
			for (int i = m - 1; i >= 0; i--) {
				juries[i] = (Integer) linkedList[1];
				linkedList = (Object[]) linkedList[2];
			}
			return juries;
		}
	}

	// -----
	// -----

	public static void main(String[] args) throws Exception {
		Judge.run("p1015.nocomment.txt");
	}

}
